package io.kiki.sba.registry.common.model.slot;


import io.kiki.sba.registry.common.model.ClientInterfaceId;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.collections.CollectionUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@Setter
@Getter

public class DataSlotDiffDigestResult implements Serializable {
    private final List<String> updatedDataInfoIds;
    private final List<String> addedDataInfoIds;
    private final List<String> removedDataInfoIds;
    @Setter
    @Getter
    private long slotsEpoch;
    // if from session, return the sessionProcessId for lease
    @Setter
    @Getter
    private ClientInterfaceId clientInterfaceId;

    public DataSlotDiffDigestResult(List<String> addedDataInfoIds, List<String> updatedDataInfoIds, List<String> removedDataInfoIds) {
        this.updatedDataInfoIds = new ArrayList<>(updatedDataInfoIds);
        this.addedDataInfoIds = new ArrayList<>(addedDataInfoIds);
        this.removedDataInfoIds = new ArrayList<>(removedDataInfoIds);
    }


    public List<String> getUpdatedDataInfoIds() {
        return Collections.unmodifiableList(updatedDataInfoIds);
    }


    public List<String> getRemovedDataInfoIds() {
        return Collections.unmodifiableList(removedDataInfoIds);
    }

    public List<String> getAddedDataInfoIds() {
        return Collections.unmodifiableList(addedDataInfoIds);
    }


    public boolean isEmpty() {
        return CollectionUtils.isEmpty(updatedDataInfoIds) && CollectionUtils.isEmpty(removedDataInfoIds) && CollectionUtils.isEmpty(addedDataInfoIds);
    }

    public int getUpdateAndAddSize() {
        return updatedDataInfoIds.size() + addedDataInfoIds.size();
    }
}
